<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="private">
		<meta content="telephone=no,email=no" name="format-detection">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta http-equiv="Access-Control-Allow-Origin" content="*" />
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>佣金记录-交易记录</title>
		
		<link rel="stylesheet" href="./css/bootstrap/css/bootstrap.css">
		<link rel="stylesheet" href="./css/common/style.css">
		<script src="./js/lib/rem.js"></script>
		<script src="./js/lib/jquery-3.3.1.min.js"></script>
		<script src="./js/lib/common.js"></script>
	</head>
	<style>
		.record{width:100%;height:100%;background:#f2f2f2;position:fixed;}
		.head{width:100%;height:1rem;line-height:1rem;text-align:center;background:#0c5dac;position:relative}
		.head-back{width:20%;height:1rem;position:absolute;left:0;top:0;text-decoration:none;outline:none;display:flex;flex-direction:row;align-items:center;justify-content:center;}
		.head-back > i.back{width:0.4rem;height:0.4rem;display:inline-block;background:url('./img/icons/left.png') no-repeat;background-size:0.4rem;}
		.head-back > span{font-size:0.3rem;color:#fff;}
		.head-title{width:100%;height:1rem;line-height:1rem;text-align:center;background:#0c5dac;}
		.head-title > span{font-size:0.34rem;color:#fff;}
		.head-back-index{width:20%;height:1rem;position:absolute;right:0;top:0;text-decoration:none;outline:none;display:flex;flex-direction:row;align-items:center;justify-content:center;}
		.head-back-index > i.back-index{width:0.6rem;height:0.6rem;display:inline-block;background:url('./img/icons/home.png') no-repeat;background-size:0.6rem;}
		
		.navTap{width:100%;height:1rem;background:#fff;border-bottom:0.02rem #ccc solid;display:flex;flex-direction:row;align-items:center;justify-content:space-around;}
		.navTap > a{display:block;width:40%;height:0.95rem;line-height:1rem;text-align:center;text-decoration:none;outline:none;}
		.navTap > a.navActive{border-bottom:0.05rem #2c64c5 solid;}
		.navTap > a.navActive > span{color:#2c64c5 !important;}
		.navTap > a > span{font-size:0.3rem;color:#222;}
		
		.navbarTap{width:100%;height:0.8rem;margin-top:0.2rem;background:#fff;}
		.navbarTap > a{display:inline-block;width:25%;height:0.8rem;text-align:center;margin:0 1%;line-height:0.8rem;text-decoration:none;outline:none;font-size:0.28rem;color:#333;}
		.navbarActive{background:#2281de !important;color:#fff !important;}
		
		.commission-contain{width:100%;height:calc(100% - 3.2rem);margin-top:0.2rem;background:#fff;}
		.commission-list{width:94%;height:calc(100% - 0.2rem);margin:0 auto 0.2rem;padding-top:0.2rem;overflow:hidden;}
		.commission-wrap{padding-bottom:0.8rem;}
		.commission-item{width:100%;height:auto;margin-bottom:0.2rem;height:1rem;display:flex;flex-direction:row;border-bottom:0.02rem solid #ccc;}
		
		.commission-state{width:65%;height:1rem;padding-left:3%;overflow:hidden;word-break:break-all;}
		.commission-state > span{display:block;width:100%;height:0.5rem;line-height:0.5rem;font-size:0.28rem;color:#222;}
		.commission-state > p{width:100%;height:0.4rem;font-size:0.24rem;color:#666;margin:0 !important;}
		.commission-money{width:35%;height:1rem;line-height:1rem;text-align:center;}
		.commission-money > span{font-size:0.32rem;color:#222;}
		
		.platform-empty{width:100%;height:4rem;display:flex;flex-direction:column;justify-content:center;align-items:center;}
		.platform-empty > img{width:1.5rem;height:1rem;}
		.platform-empty > span{font-size:0.3rem;color:#666;margin-top:0.3rem;}
		
		.loadover{width:100%;height:0.8rem;margin-top:0.2rem;text-align:center;}
		.loadover > span{color:#666;font-size:0.3rem;}
		
		
	</style>
	<body>
		<div class="record">
			<div class="head">
				<a href="./person.html" class="head-back">
					<i class="back"></i>
					<span>返回</span>
				</a>
				<div class="head-title">
					<span>交易记录</span>
				</div>
				<a href="./index.html" class="head-back-index">
					<i class="back-index"></i>
				</a>
			</div>
			<div class="navTap">
				<a href="./putforward-record.html" class="putforward">
					<span>提现记录</span>
				</a>
				<a href="./commission-task.html" class="commission navActive">
					<span>佣金记录</span>
				</a>
			</div>
			
			<div class="navbarTap">
				<a href="./commission-task.html" class="commission-task">
					<span>任务佣金</span>
				</a>
				<a href="./commission-recommend.html" class="commission-recommend navbarActive">
					<span>推荐佣金</span>
				</a>
			</div>
			
			<div class="commission-contain">
				<div class="commission-list">
					<div class="commission-wrap" id="commissionRecommendList">
						
					</div>
				</div>
			</div>
			
		</div>
		
		<!-- load state -->
		<div class="state-modal" id="loadLayer">
			<div class="statemodal-contain">
				<div class="statemodal-content">
					<div class="statemodal-icon">
						<i class="" id="loadicon"></i>
					</div>
					<div class="statemodal-text" >
						<span id="loadContext">数据加载中…</span>
					</div>
				</div>
			</div>
		</div>
		
		<div id="taskdiv"></div>
		
		<!-- putforward modal -->
		<div class="infor-modal" id="inforModal">
			<div class="infor-inner">
				<div class="infor-contain">
					<div class="informodal-title">
						<div class="modal-title">
							<span>试玩助手</span>
						</div>
					</div>
					<div class="inforModal-content">
						<span id="inforContextTitle"></span>
						<span id="inforContext"></span>
					</div>
				</div>
			</div>
		</div>
		
		<script src="./js/sendtask.js?v=1043"></script>
		<script type="text/javascript" src="./js/lib/map/maps.js"></script>
		<script src="./js/lib/mui/mui.min.js"></script>
		
		<script src="./js/lib/iscroll/iscroll.js"></script>
		
		<script>
			
			$(function(){
				var taskstate = localStorage.getItem('taskstate');
				if(taskstate === "true"){
					//after five minutes send task start
					setTimeSendTaskStart();
				}
				
				var urlip = localStorage.getItem('urlip');
				var url = 'http://'+ urlip +':8080/platform-web/';
				
				var pageIndex = '1';
				var myScroll = null;
				var pageTotal = null;
				
				//加载列表
				loadList(url,pageIndex);
				
				//after loaded scroll
				myScroll = new IScroll('.commission-list',{
					click: true,
					taps:true,
				});
				
				myScroll.on('scrollEnd',function(){
				
					if (this.maxScrollY == this.y) {
						if( pageIndex < pageTotal){
							pageIndex++;
							
							$('#loadicon').removeAttr('class').addClass('loadicon')
							$('#loadLayer').show();
							$('#loadContext').text('页面加载中...');
							
							setTimeout(function(){
								$('#loadLayer').hide();
							},1500);
							
							//加载列表
							loadList(url,pageIndex);
						}else{
							if( !( $('#commissionRecommendList').children('div').hasClass('loadover') ) ){
								$('#commissionRecommendList').append('<div class="loadover"><span>没有更多数据了...</span></div>')
							}
						}
					}
				})
				
				function loadList(url,pageIndex){
					var userid = localStorage.getItem('userid');
					if(userid){
						$.ajax({
							type:'POST',
							url:url+'commission/commissionList',
							dataType:'json',
							data:{
								id:userid,
								type:1, //推荐佣金
								pageNum:pageIndex, //当前页
								pageDataCount:10 //每页的数据条数
							},
							success:function(data){
								if(data.code === 403){
									location.href = './login.html'
								}else if(data.code === 404){
									alert('设备被锁')
								}else if(data.code === 5000 ){
									
									pageTotal = data.pages;
									if(data.pageList.length !== 0){
										var comTaskListHtml = '';
										for(var i=0;i<data.pageList.length;i++){
											comTaskListHtml += '<div class="commission-item"><div class="commission-state"><span>获得推荐佣金</span>'+
																'<p>'+ data.pageList[i].strGetTime +'</p>'+
																'</div><div class="commission-money">'+
																'<span>+ '+ data.pageList[i].strCommission +'</span>'+
																'</div></div>'
										}
													
										$('#commissionRecommendList').append(comTaskListHtml);
										myScroll.refresh();
									}else{
										myScroll.destroy();
										$('#commissionRecommendList').html('<div class="platform-empty"><img src="./img/icons/no-record.png" alt=""><span>暂无数据</span></div>');
									}
								}
							}
						});
					}else{
						setTimeout(function(){
							location.href = './login.html'
						},1500)
					}
				}
				
				
			});
			
		</script>
		
	</body>
</html>
